home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 460 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.0 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: wikman@research.nokia.com (Johan Wikman)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Problem with template overloading.
  5. Date: 23 Feb 1996 15:55:23 GMT
  6. Organization: ?
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <9602231434.AA15034@garlic.spices>
  9. NNTP-Posting-Host: taumet.eng.sun.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset="ISO-8859-1"
  12. Content-Transfer-Encoding: 8bit
  13. X-Mailer: ELM [version 2.4 PL24alpha5]
  14. X-Lines: 34
  15. Content-Length: 1194
  16. Originator: clamage@taumet
  17.  
  18. In article <4gi7h0$l0@engnews1.Eng.Sun.COM> clamage@Eng.Sun.COM (Steve Clamage) writes:
  19.  
  20. >  In article AA11584@garlic.spices, wikman@research.nokia.com (Johan Wikman)
  21. >  writes:
  22. >
  23. >  >I'd like to be able to have a class and a template with the same name
  24. >  >in the same scope. 
  25. >
  26. >       class A { ... };
  27. >
  28. >       template <class T>
  29. >       class A {
  30. >           void foo() { .... A ... }
  31. >       };
  32. >
  33. >   In A<T>::foo, I use the identifier "A". Does that refer to the template
  34. >   or to the class? In order not to break all existing code, it must
  35. >   refer to the template. 
  36.  
  37. Interesting, I always thought you had to use A<T>. Now that I tried
  38. it, all compilers I have access to (HP, gcc and MS VC++) accepted both
  39. A and A<T>. What does the standard say? Are both versions allowed?
  40.  
  41. >   Perhaps you can think of a special syntax that won't change the meaning
  42. >   of existing code, or we could say that you can't refer to class A anywhere
  43. >   in the scope of template A. 
  44.  
  45. No, I won't even try. But I definitely find using A<T> within the
  46. definition of a template's function more intuitive than just using
  47. A. Making A<T> a requirement certainly wouldn't break my code;-). 
  48.  
  49. --
  50. johan.wikman@research.nokia.com
  51.  
  52.  
  53. [ To submit articles: Try just posting with your newsreader.
  54.               If that fails, use mailto:std-c++@ncar.ucar.edu
  55.   FAQ:    http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  56.   Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  57.   Comments? mailto:std-c++-request@ncar.ucar.edu
  58. ]
  59.